**Factor Analysis in Stata
clear all
use "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\The Fruits of Faith\Religion-Becoming Scale\BigKU 2020 recoded.dta" 
**Alpha of 0.72
alpha Q4_1_1 Q4_1_2 Q4_1_3 Q4_1_4 Q4_1_5 Q4_1_6 Q4_1_7 Q4_1_8 Q4_1_9 Q4_1_10
//EFA analyses
factor Q4_1_1 Q4_1_2 Q4_1_3 Q4_1_4 Q4_1_5 Q4_1_6 Q4_1_7 Q4_1_8 Q4_1_9 Q4_1_10, comp(5)
rotate, promax normalize
sortl
**Bartlett test of sphericity and Kaiser-Meyer-Olkin 
factortest Q4_1_1- Q4_1_10

**Descriptive Statistcs Table A3
**Recode each item 0-1
gen rb1=( Q4_1_1/7)
gen rb2=( Q4_1_2/7)
gen rb3=( Q4_1_3/7)
gen rb4=( Q4_1_4/7)
gen rb5=( Q4_1_5/7)
gen rb6=( Q4_1_6/7)
gen rb7=( Q4_1_7/7)
gen rb8=( Q4_1_8/7)
gen rb9=( Q4_1_9/7)
gen rb10=( Q4_1_10/7)

dtable rb1 rb2 rb3 rb4 rb5 rb6 rb7 rb8 rb9 rb10
summarize rb1-rb10, detail


**Test for multivariate normality prior to CFA... Not multivariate normal
mvtest normality Q4_1_1 - Q4_1_10, stats(all)
**If not multivariate normal use weighted least squares estimator
**One-factor solution
sem (L1 -> Q4_1_9 Q4_1_10) (L2 -> Q4_1_3 Q4_1_4 Q4_1_8) (L3 -> Q4_1_2 Q4_1_7), latent (L1 L2 L3) method(adf) standardized
estat gof, stats(all)
**Satorra Bentler
sem (L1 -> Q4_1_1 Q4_1_2 Q4_1_3 Q4_1_4 Q4_1_5 Q4_1_6 Q4_1_7 Q4_1_8  Q4_1_9 Q4_1_10), latent (L1) standardized vce(sbentler)

**or use the robust corrected standard errors
sem (L1 -> Q4_1_9 Q4_1_10) (L2 -> Q4_1_3 Q4_1_4 Q4_1_6 Q4_1_8) (L3 -> Q4_1_1 Q4_1_2 Q4_1_5 Q4_1_7), latent (L1 L2 L3) vce(robust)
estat gof, stats(all)

**Three-factor solution
sem (L1 -> Q4_1_9 Q4_1_10) (L2 -> Q4_1_3 Q4_1_4 Q4_1_6 Q4_1_8) (L3 -> Q4_1_1 Q4_1_2 Q4_1_5 Q4_1_7), latent (L1 L2 L3) standardized vce(sbentler)
estat gof, stats(all)

//The following shows that my three religion factors are distinct from Spirituality.
sem (L1 -> Q4_1_9 Q4_1_10) (L2 -> Q4_1_3 Q4_1_4 Q4_1_6 Q4_1_8) (L3 -> Q4_1_1 Q4_1_2 Q4_1_5 Q4_1_7) (L4 -> Q6_4_1- Q6_9_1 ), latent (L1 L2 L3 L4) vce(bootstrap) standardized
estat gof, stats(all)

**Four-factor solution
sem (L1 -> Q4_1_9 Q4_1_10) (L2 -> Q4_1_3 Q4_1_4 Q4_1_6 Q4_1_8) (L3 -> Q4_1_2  Q4_1_1) (L4 -> Q4_1_5 Q4_1_7 ), latent (L1 L2 L3 L4)  cov(e.Q4_1_3*e.Q4_1_6) standardized vce(sbentler)
estat gof, stats(all)

**However, the model that fits the theory the best, and has the best AIC/BIC, and has ok SEM fit indices is the following model
sem (L1 -> Q4_1_9 Q4_1_10) (L2 -> Q4_1_3 Q4_1_4 Q4_1_6 Q4_1_8) (L3 -> Q4_1_2  Q4_1_1) (L4 -> Q4_1_5 Q4_1_7 ) (L5 -> Q6_4_1- Q6_9_1 ), latent (L1 L2 L3 L4 L5)  cov(e.Q4_1_3*e.Q4_1_6) standardized vce(bootstrap)
estat gof, stats(all)



********************************BIG KU 2021*********************************************************************

clear all
**The 2021 National Survey explicitly excluded any component of religion from the scale. It is purely measuring Values in Action--Separate from religion.
use "C:\Users\mrm32\OneDrive - BYU-Idaho\Data\KU Surveys\Big-KU-2021\Big-KU-2021-recode.dta"
**The 2021 Survey automatically created some of the scales.
**Look at the factor loadings.

**Temperance = Q38_7 Q38_8 Q38_9
**Transcendance = Q38_10 Q38_11 Q38_12
**Humanity = Q38_1 Q38_2 Q38_3
**Justice = Q38_4 Q38_5 Q38_6

**The Values in Action Items are a worse model fit than Religious Becoming
**CFI=0.912, TLI = 0.878, RMSEA=0.069, SRMR = 0.044
sem (Temperance -> Q38_7 Q38_8 Q38_9) (Transcendance -> Q38_10 Q38_11 Q38_12) (Humanity -> Q38_1 Q38_2 Q38_3) (Justice -> Q38_4 Q38_5 Q38_6) , latent (Temperance Transcendance Humanity Justice) vce(sbentler) standardized
estat gof, stats(all)

**Moral Traditionalism = Q23 Q24 (r) Q25 Q26 (r)
**rr = Q28 Q29 Q30 Q31
**CN = Q71_1 Q71_2 Q71_3 Q71_4 Q71_5 Q71_6

**Recode Items for correlation matrix
gen nv = ( temperance+ transcendence+ humanity+ justice)
gen via = (nv-12)/48
gen CNr = (CN-6)/24
gen RRr = ( rr -6)/14
gen relnet = ( religNet/5)
gen Belief = ( belief /100)
//generational change
gen gen=.
replace gen=1 if age<30
replace gen =2 if age>29 & age<45
replace gen =3 if age>44 & age<60
replace gen =4 if age>59 & age<79
replace gen =5 if age>78 & age!=.
label define gv 1 "Gen Z" 2 "Millennial" 3"Gen X" 4"Boomer" 5"Silent"
label values gen gv


corr via CNr RRr relnet Belief
**Generational differences in via
graph bar via , over(gen) blabel(total)
**Make figures showing that via (Values in Action) is not religion-based.
graph bar via , over( affiliation ) blabel(total)
graph bar via , over( pray ) blabel(total)
graph bar via , over( attend ) blabel(total)
**Code religiosity and make a similar figure.

***via is positively associated with Christian Nationalism
reg CNr via RRr relnet Belief pray religimport raceID i.bornagain sex income polknow auth ib4.ideo i.PartyID, robust

**via is not associated with trust in religious leaders
ologit Q7_7 via RRr relnet Belief pray religimport raceID i.bornagain sex income polknow auth ib4.ideo i.PartyID ib3.gen, robust

**via ""if elected leaders will not protect America, the people must do it themselves, even if it requires violent actions." Q53

**via The traditional American way of life is disappearing so fast that we may have to use force to save it." Q54

//recode religious variables and psychological scales variables 0-1 so they can be compared with via
gen cn=(CN -6)/24
gen rbelief = (belief/100)
gen relignet = (religNet/5)
gen bem = (BEM-10)/36
gen Auth = (auth-1)/7
gen sct = (SCT-4)/16
gen Egal = (egal-4)/16
gen Moraltrad = (moraltrad-4)/16
**Create dichtomous IVs for categorical variables for plotting.
gen idrelig = 0
replace idrelig = 1 if religID==1
gen importrelig = 0
replace importrelig = 1 if religimport==1
gen Attend = 0
replace Attend = 1 if attend==1
gen Pray = 0
replace Pray = 1 if pray==1

alpha Q38_1-Q38_12
*Average interitem covariance:     .3028585
*Number of items in the scale:           12
*Scale reliability coefficient:      0.8200



reg via rbelief relignet idrelig importrelig Attend Pray cn, robust
coefplot, xline(0) xscale(range(-0.1, 0.4))
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\2001 via coeffplot.grec"
graph export "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\2001 via coeffplot.png", as(png) name("Graph")

**Include other psychological scales
reg via rbelief relignet idrelig importrelig Attend Pray cn RRr Auth sct Egal Moraltrad  , robust
coefplot, drop(_cons) xline(0)
graph save "Graph" "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\2001 via coeffplot (psych).gph", replace
graph export "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\2001 via coeffplot (psych).png", as(png) name("Graph")


**Interested generational differences in trust items
ologit Q7_7 via RRr relnet Belief pray religimport raceID i.bornagain sex income polknow auth ib4.ideo i.PartyID ib3.gen, robust
ologit Q7_4 via RRr relnet Belief pray religimport raceID i.bornagain sex income polknow auth ib4.ideo i.PartyID ib3.gen, robust
ologit Q7_8 via RRr relnet Belief pray religimport raceID i.bornagain sex income polknow auth ib4.ideo i.PartyID ib3.gen, robust
ologit Q7_9 via RRr relnet Belief pray religimport raceID i.bornagain sex income polknow auth ib4.ideo i.PartyID ib3.gen, robust

*******************************2022*********************************************************************
**Replicate with the KU 2022 Data
clear all
//use "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Analyses\fof2022 replication data.dta"
use "C:\Users\mrm32\OneDrive - BYU-Idaho\Data\KU Surveys\Big-KU-2022\Big-KU-2022 (affpol).dta"
//Religious Becoming is not associated with Affective Polarization
gen rb = ((Q4_1_1+ Q4_1_2+ Q4_1_3+ Q4_1_4+ Q4_1_5+ Q4_1_6+ Q4_1_7+ Q4_1_8+ Q4_1_9+ Q4_1_10)-10)/60

alpha Q4_3_1-Q4_3_10
//Test scale = mean(unstandardized items)
//Reversed item:  Q4_3_1
//Average interitem covariance:     .1851283
//Number of items in the scale:           10
//Scale reliability coefficient:      0.6145
gen Q4_3_1r = (6- Q4_3_1)
gen rb=((Q4_3_1r+ Q4_3_2+ Q4_3_3+ Q4_3_4+Q4_3_5+ Q4_3_6+ Q4_3_7+ Q4_3_8+ Q4_3_9 +Q4_3_10)-14)/36

**IS Religious Becoming three factor solution.  
***CFI= 0.877, TLI =  0.821, RMSEA= 0.083 , SRMR = 0.069
sem (L1 -> Q4_3_9 Q4_3_10) (L2 -> Q4_3_3 Q4_3_4 Q4_3_6 Q4_3_8) (L3 -> Q4_3_2  Q4_3_1 Q4_3_5 Q4_3_7 ), latent (L1 L2 L3) cov(e.Q4_3_3*e.Q4_3_6) vce (sbentler)standardized
estat gof, stats(all)

**IS Religious Becoming four factor solution.  
***CFI= 0.881, TLI =  0.809, RMSEA= 0.086 , SRMR = 0.068
sem (L1 -> Q4_3_9 Q4_3_10) (L2 -> Q4_3_3 Q4_3_4 Q4_3_6 Q4_3_8) (L3 -> Q4_3_2  Q4_3_1) (L4 -> Q4_3_5 Q4_3_7 ), latent (L1 L2 L3 L4) cov(e.Q4_3_3*e.Q4_3_6) vce (sbentler)standardized
estat gof, stats(all)

**IS Religious Becoming Distinct from all Moral Foundations?  Just use the correlation matrix.
***CFI= 0.883, TLI =  0.869, RMSEA= 0.059 , SRMR = 0.077
sem (L1 -> Q4_3_9 Q4_3_10) (L2 -> Q4_3_3 Q4_3_4 Q4_3_6 Q4_3_8) (L3 -> Q4_3_2  Q4_3_1) (L4 -> Q4_3_5 Q4_3_7 ) (Spirit -> Q4_6_1- Q4_11_1 )(Harm -> Q4_1_1 Q4_1_2 Q4_1_3 Q4_2_1 Q4_2_6 Q4_2_11 )(Fair -> Q4_1_4 Q4_1_5 Q4_1_6 Q4_2_2 Q4_2_7 Q4_2_12 )(Ingroup -> Q4_1_7 Q4_1_8 Q4_1_9 Q4_2_3 Q4_2_8 Q4_2_13), latent (L1 L2 L3 L4 Spirit Harm Fair Ingroup) vce (sbentler) standardized
estat gof, stats(all)

**How do moral foundations fit?
***Much worse than mine
***CFI= 0.733, TLI =  0.706, RMSEA= 0.079 , SRMR = 0.096
sem (Harm -> Q4_1_1 Q4_1_2 Q4_1_3 Q4_2_1 Q4_2_6 Q4_2_11 )(Fair -> Q4_1_4 Q4_1_5 Q4_1_6 Q4_2_2 Q4_2_7 Q4_2_12 )(Ingroup -> Q4_1_7 Q4_1_8 Q4_1_9 Q4_2_3 Q4_2_8 Q4_2_13) (Authority -> Q4_1_12 Q4_1_10 Q4_1_11 Q4_2_4 Q4_2_9 Q4_2_14) (Purity -> Q4_1_13 Q4_1_14 Q4_1_15 Q4_2_5 Q4_2_10 Q4_2_15), latent (Harm Fair Ingroup Authority Purity) vce (sbentler) standardized
estat gof, stats(all)

**Religiosity
sem (relig -> Q5_4 attend pray scripture saygrace relwork relhome belgod ), latent (relig) vce (sbentler) standardized
estat gof, stats(all)

**The Values in Action Items are a worse model fit than Religious Becoming
**CFI=0.902, TLI = 0.856, RMSEA=0.066, SRMR = 0.048
sem (Temperance -> Q8_1_7 Q8_1_8 Q8_1_9) (Transcendance -> Q8_1_10 Q8_1_11 Q8_1_12) (Humanity -> Q8_1_1 Q8_1_2 Q8_1_3) (Justice -> Q8_1_4 Q8_1_5 Q8_1_6) , latent (Temperance Transcendance Humanity Justice) vce(sbentler) standardized
estat gof, stats(all)

**8 factor solution VIA and RB
**CFI=0.892, TLI = 0.78, RMSEA=0.066, SRMR = 0.067
sem (L1 -> Q4_3_9 Q4_3_10) (L2 -> Q4_3_3 Q4_3_4 Q4_3_6 Q4_3_8) (L3 -> Q4_3_2  Q4_3_1) (L4 -> Q4_3_5 Q4_3_7 )(Temperance -> Q8_1_7 Q8_1_8 Q8_1_9) (Transcendance -> Q8_1_10 Q8_1_11 Q8_1_12) (Humanity -> Q8_1_1 Q8_1_2 Q8_1_3) (Justice -> Q8_1_4 Q8_1_5 Q8_1_6), latent (L1 L2 L3 L4 Temperance Transcendance Humanity Justice) cov(e.Q4_3_3*e.Q4_3_6) vce(sbentler) standardized
estat gof, stats(all)

**In a four-factor EFA, the rb items do not load with the via items
factor Q8_1_1- Q8_1_12 Q4_3_1 Q4_3_2 Q4_3_3 Q4_3_4 Q4_3_5 Q4_3_6 Q4_3_7 Q4_3_8 Q4_3_9 Q4_3_10 , comp(4)
rotate, promax normalize
sortl

**In a four-factor EFA, the rb items do not load with the via items
factor Q8_1_1- Q8_1_12, comp(4)
rotate, promax normalize
sortl

//recode religious variables and psychological scales variables 0-1 so they can be compared with via
gen bem =(sexrole + 2.618053)/6
gen Auth = (auth+ 1.770718)/3.472094
gen SCT = (sct+1.820503)/3.919924
gen temperance = (temp+2.988249)/4.958
gen transcendence = (transc+3.187123)/4.72
gen humanity = (hum+4.085228)/5.75
gen justice = (just+3.17195)/5
gen via = ( temperance+ transcendence+ humanity+ justice)
**Rescale moral foundations to 0-1 scales
gen Purity = (purity +3.625616)/5.58
gen Authority = ( authority +2.669384)/4.74
gen Ingroup = ( ingroup +3.951167)/5.79
gen Fairness = ( fairness +4.02134)/5.74
gen Harm = ( harm +1.461225)/3.382
gen spirituality = ( spirit +2.322741)/4.72
**Create dichtomous IVs for categorical variables for plotting.
gen Rural = 0
replace Rural = 1 if rural==5
gen rich=0
replace rich = 1 if income==3
gen highrid=0
replace highrid=1 if religID==1
gen white=0
replace white=1 if race==1
gen conservative=0
replace conservative=1 if ideo5p==5
replace conservative=1 if ideo5p==4
gen repub=0
replace repub=1 if PartyID==3
gen importrelig = 0
replace importrelig = 1 if religimport==4
gen Pray = 0
replace Pray = 1 if pray==1
replace Pray = 1 if saygrace==1
gen Attend = 0
replace Attend = 1 if attend==1
gen rbelief = 0
replace rbelief = 1 if belgod==1

*via composite score
alpha Q8_1_1- Q8_1_12
*Average interitem covariance:     .3055628
*Number of items in the scale:           12
*Scale reliability coefficient:      0.8143


**Only include religion as a predictor
**copy 2021 exactly
reg via rbelief relnet highrid importrelig Attend Pray CNr, robust
coefplot, drop(_cons) xline(0)
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\2001 via coeffplot.grec"
**Use other measures
reg via rbelief relnet highrid importrelig Attend Pray CNr spirituality Auth SCT Purity Authority Ingroup Fairness Harm, robust
coefplot, drop(_cons) xline(0)
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\2001 via coeffplot.grec"
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\2022 via coeffplot psychometric"

**Add in moral foundations
reg via religiosity relnet highrid evangelical CNr spirituality Auth SCT Purity Authority Ingroup Fairness Harm , robust
coefplot, drop(_cons) xline(0)

//Compare those figures with Religious Becoming
**Only include religion as a predictor
**copy 2021 exactly
reg rb rbelief relnet highrid importrelig Attend Pray CNr, robust
coefplot, drop(_cons) xline(0)
//coefplot, drop(_cons) xline(0) xscale(range(-0.1 0.3))
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\2001 via coeffplot.grec"
graph export "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\Images\2022 rb coeffplot.png", as(png) name("Graph1") replace
**Add in psychological scales
**Use other measures
reg rb rbelief relnet highrid importrelig Attend Pray CNr spirituality Auth SCT Purity Authority Ingroup Fairness Harm, robust
coefplot, drop(_cons) xline(0)
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\2001 via coeffplot.grec"
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\2022 via coeffplot psychometric"

//Making plots is silly. Present the appendix information in a table instead.
reg via rbelief relnet highrid importrelig Attend Pray CNr, robust 
outreg2 using "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\A-14reg.doc", replace label ctitle(Values in Action) stats(coef se) sym(***,**,*) dec(3)
reg rb rbelief relnet highrid importrelig Attend Pray CNr, robust
outreg2 using "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\A-14reg.doc", append label ctitle(Religious Becoming) stats(coef se) sym(***,**,*) dec(3)
reg via rbelief relnet highrid importrelig Attend Pray CNr RRr spirituality Auth SCT Purity Authority Ingroup Fairness Harm, robust
outreg2 using "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\A-14reg.doc", append label ctitle(Values in Action) stats(coef se) sym(***,**,*) dec(3)
reg rb rbelief relnet highrid importrelig Attend Pray CNr RRr spirituality Auth SCT Purity Authority Ingroup Fairness Harm, robust
outreg2 using "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\A-14reg.doc", append label ctitle(Religious Becoming) stats(coef se) sym(***,**,*) dec(3)

corr relbec purity authority ingroup fairness harm religiosity
*             |   relbec   purity authority  ingroup fairness     harm religiosity
*-------------+---------------------------------------------------------------
*      relbec |   1.0000
*      purity |   0.3892   1.0000
*   authority |   0.3588   0.7088   1.0000
*     ingroup |   0.2243   0.4828   0.4553   1.0000
*    fairness |   0.3250   0.5380   0.4651   0.7419   1.0000
*        harm |   0.6784   0.3695   0.4303   0.1569   0.1915   1.0000
* religiosity |   0.9222   0.4196   0.4302   0.2216   0.2928   0.7527   1.0000

**Rescale moral foundations to 0-1 scales
gen Purity = (purity +3.625616)/5.58
gen Authority = ( authority +2.669384)/4.74
gen Ingroup = ( ingroup +3.951167)/5.79
gen Fairness = ( fairness +4.02134)/5.74
gen Harm = ( harm +1.461225)/3.382
gen spirituality = ( spirit +2.322741)/4.72

corr rb CNr relnet RRr religr Purity Authority Ingroup Fairness Harm spirituality

 //            |       rb   purity author~y  ingroup fairness     harm religi~y
//-------------+---------------------------------------------------------------
 //         rb |   1.0000
 //     purity |   0.4395   1.0000
 //  authority |   0.4988   0.7066   1.0000
//     ingroup |   0.3718   0.4774   0.4505   1.0000
//    fairness |   0.3950   0.5311   0.4605   0.7393   1.0000
//        harm |   0.5786   0.3691   0.4270   0.1540   0.1882   1.0000
// religiosity |   0.6362   0.4208   0.4298   0.2191   0.2909   0.7555   1.0000


********************************2024*********************************************************************
clear all
**Replicate with the BYU-I 2024 Data
use "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Analyses\fof2024 replication data.dta"
**Theoretical Model, poor fit statistics, poor  loadings. Model should be rejected
sem (Temperance -> Q21_1 Q21_2 Q21_11 Q21_12 ) (Transcendance -> Q21_9 Q21_10 Q21_15 Q21_16 ) (Humanity -> Q21_3 Q21_4 Q21_6 Q21_8 ) (Justice -> Q21_5 Q21_7 Q21_13 Q21_14 ) , latent (Temperance Transcendance Humanity Justice) vce(sbentler) standardized
estat gof, stats(all)
**Just stick with the EFA Four factor solution. Some items fit differently than theoretical expectations, but they do fit. Humanity and Justice are hard to distinguish as different dimensions. 6,13,15 just load together for some reason.
//EFA analyses
factor Q21_1 Q21_2 Q21_3 Q21_4 Q21_5 Q21_6 Q21_7 Q21_8 Q21_9 Q21_10 Q21_11 Q21_12 Q21_13 Q21_14 Q21_15 Q21_16, comp(4)
rotate, promax normalize
sortl

alpha Q21_1 Q21_2 Q21_3 Q21_4 Q21_5 Q21_6 Q21_7 Q21_8 Q21_9 Q21_10 Q21_11 Q21_12 Q21_13 Q21_14 Q21_15 Q21_16
**Use the EFA to show the structure of these data. Use the CFA to show that these four factors are distinct from spirituality and religiosity.

**Based on the EFA, the best four factors are:
***CFI= 0.878, TLI =  0.850, RMSEA= 0.060 , SRMR = 0.063
sem (F1 -> Q21_15 Q21_13 Q21_6 ) (F2 -> Q21_9 Q21_10 Q21_16 ) (F3 -> Q21_3 Q21_4 Q21_14 Q21_8 Q21_11 ) (F4 -> Q21_1 Q21_2 Q21_5 Q21_7 Q21_12 ), cov( F1*F2 F1*F3 F1*F4 F2*F3 F3*F4 F4*F2) latent (F1 F2 F3 F4) vce(sbentler) standardized
estat gof, stats(all)
**Add in spirituality & religiosity
***CFI= 0.942, TLI =  0.935, RMSEA= 0.048 , SRMR = 0.056
sem (F1 -> Q21_15 Q21_13 Q21_6 ) (F2 -> Q21_9 Q21_10 Q21_16 ) (F3 -> Q21_3 Q21_4 Q21_14 Q21_8 Q21_11 ) (F4 -> Q21_1 Q21_2 Q21_5 Q21_7 Q21_12 ) (Spirit -> Q23_1-Q28_1) (Religiosity -> Q37 Q38 Q39 Q40 Q44 Q45) , latent (F1 F2 F3 F4 Spirit Religiosity) cov( F1*F2 F1*F3 F1*F4 F2*F3 F3*F4 F4*F2) vce(sbentler) standardized
estat gof, stats(all)
// Hu and Bentler (1999) suggest that to confirm adequate fit for a model, CFI should ideally be greater than .95, RMSEA should be less than .06, and SRMR should be less than .08

//Compare with other Scales
**Secularism CFI= 0.785, TLI =  0.700, RMSEA= 0.096 , SRMR = 0.074
sem (polsec -> Q53 Q54_1 Q54_2 Q54_3 Q54_4 Q54_5 Q54_6 Q55 ), latent (polsec) vce (sbentler) standardized
estat gof, stats(all)

**Post-materialist Values CFI= 0.882, TLI =  0.804, RMSEA= 0.072 , SRMR = 0.047
sem (pm12 -> Q29 Q30 Q31 Q32 Q33 Q34), latent (pm12) vce (sbentler) standardized
estat gof, stats(all)

**Correlation Matrix
**All items are already coded 0-1
corr rb spirituality pm12 CN religiosity secular

**Create 2024 Survey Figure
reg rb religiosity relnet highrid evangelical CN spirituality , robust
coefplot, drop(_cons) xline(0)
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\2022 via relig coeffplot.grec"
graph export "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\Images\2024 rb coeffplot.png", as(png) name("Graph")


//Chapter 4 Christian Nationalism
//Religious Becoming is negatively associated with Christian Nationalism, Values in Action are positively associated with Christian nationalism.
//Figures for the book and the alternative model specification for the appendix
reg CNr via religr relnet highrid evangelical RRr repub conservative white Rural rich, robust
coefplot, drop(_cons) xline(0)
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Christian Nationalism\coefficient plot.grec"
graph export "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\Images\CN by VIA.png", as(png) name("Graph") replace

//Chapter 5 Political Tolerance
//Replicate with VIA for the appendix
reg Tdisc via religr relnet highrid evangelical RRr repub conservative white Rural rich CNr auth age, robust
coefplot, drop(_cons) xline(0)
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Christian Nationalism\coefficient plot.grec"
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Political Tolerance\coefficient plot (additional variables).grec
graph export "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\Images\Figure 5-3 Tdisc.png", as(png) name("Graph")

//Replicate with VIA for the appendix
reg Rdisc via religr relnet highrid evangelical RRr repub conservative white Rural rich CNr auth age, robust
coefplot, drop(_cons) xline(0)
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Christian Nationalism\coefficient plot.grec"
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Political Tolerance\coefficient plot (additional variables).grec
graph export "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\Images\Figure 5-1 RDisc.png", as(png) name("Graph")

//Replicate with VIA for the appendix
reg Wdisc via religr relnet highrid evangelical RRr repub conservative white Rural rich CNr auth age, robust
coefplot, drop(_cons) xline(0)
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Christian Nationalism\coefficient plot.grec"
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Political Tolerance\coefficient plot (additional variables).grec
graph export "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\Images\Figure 5-2 WDisc.png", as(png) name("Graph")

//Replicate with VIA for the appendix
reg GLdisc via religr relnet highrid evangelical RRr repub conservative white Rural rich CNr auth age, robust
coefplot, drop(_cons) xline(0)
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Christian Nationalism\coefficient plot.grec"
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Political Tolerance\coefficient plot (additional variables).grec
graph export "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\Images\Figure 5-3 GLdisc.png", as(png) name("Graph")




//Chapter 6
//Violation of Democratic Norms Religious Becoming
ologit Q26_2 RB evangelical sex religiosity spirit auth CNr RRr relnet highrid white conservative repub age Rural, robust
outreg2 using "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\A-6-3ologit.doc", replace label ctitle(Emergency Powers) stats(coef se) sym(***,**,*) dec(3)
ologit Q26_3 RB evangelical sex religiosity spirit auth CNr RRr relnet highrid white conservative repub age Rural, robust
outreg2 using "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\A-6-3ologit.doc", label ctitle(Bend Rules) stats(coef se) sym(***,**,*) dec(3)
ologit Q26_4 RB evangelical sex religiosity spirit auth CNr RRr relnet highrid white conservative repub age Rural, robust
outreg2 using "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\A-6-3ologit.doc", label ctitle(Protect America) stats(coef se) sym(***,**,*) dec(3)
ologit Q26_6 RB evangelical sex religiosity spirit auth CNr RRr relnet highrid white conservative repub age Rural, robust
outreg2 using "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\A-6-3ologit.doc", label ctitle(Push Collapse) stats(coef se) sym(***,**,*) dec(3)
ologit Q26_7 RB evangelical sex religiosity spirit auth CNr RRr relnet highrid white conservative repub age Rural, robust
outreg2 using "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\A-6-3ologit.doc", label ctitle(Vigilante) stats(coef se) sym(***,**,*) dec(3)

//Violation of Democratic Norms Values in Action
ologit Q26_2 via evangelical sex religiosity spirit auth CNr RRr relnet highrid white conservative repub age Rural, robust
outreg2 using "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\A-6-3 (VIA).doc", replace label ctitle(Emergency Powers) stats(coef se) sym(***,**,*) dec(3)
ologit Q26_3 via evangelical sex religiosity spirit auth CNr RRr relnet highrid white conservative repub age Rural, robust
outreg2 using "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\A-6-3 (VIA).doc", label ctitle(Bend Rules) stats(coef se) sym(***,**,*) dec(3)
ologit Q26_4 via evangelical sex religiosity spirit auth CNr RRr relnet highrid white conservative repub age Rural, robust
outreg2 using "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\A-6-3 (VIA).doc", label ctitle(Protect America) stats(coef se) sym(***,**,*) dec(3)
ologit Q26_6 via evangelical sex religiosity spirit auth CNr RRr relnet highrid white conservative repub age Rural, robust
outreg2 using "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online AppendixA-6-3 (VIA).doc", label ctitle(Push Collapse) stats(coef se) sym(***,**,*) dec(3)
ologit Q26_7 via evangelical sex religiosity spirit auth CNr RRr relnet highrid white conservative repub age Rural, robust
outreg2 using "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\A-6-3 (VIA).doc", label ctitle(Vigilante) stats(coef se) sym(***,**,*) dec(3)

//Create a coefficient plot for the book (Figure 6.1)
//Replicate with VIA for the appendix
reg Q26_10 via religr relnet highrid evangelical RRr repub conservative white Rural rich CNr auth age, robust
coefplot, drop(_cons) xline(0)
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Christian Nationalism\coefficient plot.grec"
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Political Tolerance\coefficient plot (additional variables).grec
graph export "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\Images\Figure 6-1 Tdisc.png", as(png) name("Graph") replace
//Replicate with VIA for the appendix
reg Q26_11 via religr relnet highrid evangelical RRr repub conservative white Rural rich CNr auth age, robust
coefplot, drop(_cons) xline(0)
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Christian Nationalism\coefficient plot.grec"
graph play "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Chapter Outlines\Political Tolerance\coefficient plot (additional variables).grec
graph export "C:\Users\mrm32\OneDrive - BYU-Idaho\Religious Becoming Book Project\Online Appendix\Images\Figure 6-2 civilians.png", as(png) name("Graph") replace






